package com.fuluwa.domain.bank.service;

import java.math.BigDecimal;
import java.util.List;

import com.fuluwa.domain.bank.model.Account;
import com.fuluwa.domain.bank.model.EarningDefine;
import com.fuluwa.infra.event.GlobalEvent;
import com.google.common.collect.Lists;

public class EarningDefineHelper
{
  private static List<EarningDefine> list = Lists.newArrayList();
  private static EarningDefineHelper instance = new EarningDefineHelper();

  private EarningDefineHelper() {
    list.add(new EarningDefine(GlobalEvent.EventType.REGISTED, Account.AccountType.SILVER, new BigDecimal(10.0D)));
    list.add(new EarningDefine(GlobalEvent.EventType.PRODUCT_ONLINE, Account.AccountType.SILVER, new BigDecimal(20.0D)));
  }

  public EarningDefine find(GlobalEvent.EventType eventType, Account.AccountType accountType) {
    for (EarningDefine def : list) {
      if (def.equals(new EarningDefine(eventType, accountType)))
        return def;
    }
    return null;
  }

  public static EarningDefineHelper getInstance() {
    return instance;
  }
}